<template>
  <div class="sidebar-logo" :class="{ collapses: collapse }">
    <transition name="sidebar-logo-fade">
      <div class="sidebar-logo-inner" v-if="collapse">
        <img :src="getLogo()" alt="logo" />
        <span class="sidebar-title">{{ title }}</span>
      </div>
      <div class="sidebar-logo-inner" v-else>
        <img :src="getLogo()" alt="logo" />
        <span class="sidebar-title">{{ title }}</span>
      </div>
    </transition>
  </div>
</template>
<script setup lang="ts">
import { computed } from "vue";
import { getConfig } from "@/config";
defineOptions({
  name: "SidebarLogo"
});
defineProps({
  collapse: Boolean
});
/** 获取`logo` */
const getLogo = () => {
  return new URL("/vite.svg", import.meta.url).href;
};
/** 标题 */
const title = computed(() => {
  const config = getConfig();
  return config.Title;
});
</script>
<style scoped lang="scss">
.sidebar-logo {
  position: relative;
  width: 100%;
  height: 48px;
  overflow: hidden;
  .sidebar-logo-inner {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    height: 100%;
    padding-left: 10px;
    img {
      display: inline-block;
      height: 32px;
    }
    .sidebar-title {
      display: inline-block;
      height: 32px;
      margin: 2px 0 0 12px;
      overflow: hidden;
      font-size: 18px;
      font-weight: 600;
      line-height: 32px;
      color: #000000d9;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
  }
}
</style>
